home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #12 / Amiga Plus CD - 2002 - No. 12.iso / AmigaOS / Aplus_Dev / AP-Website / artikel / rebol / rebol.lha / birthdays.r next >
Encoding:
Text File  |  1999-03-15  |  2.3 KB  |  118 lines

  1. REBOL [
  2.   Title: "Birthdays"
  3.   Date:  1998/12/30
  4.   File: %birthdays.r
  5.   Version: 1.0
  6.   Purpose: "Send Birthday Greetings to your friends"
  7. ]
  8.  
  9. birthdays: make object! 
  10. [
  11.   choice: 1
  12.  
  13.   loadFriends: make function! []
  14.   [
  15.     if (exists? %friends.dat) [ friends: load %friends.dat ]
  16.     else friends: []
  17.   ]
  18.  
  19.   displayMenu: make function! []
  20.   [
  21.     print ""
  22.     print "   Welcome to our little birthday Reminder"
  23.     print "   Make your choice:"
  24.     print ""
  25.     print "   1 - Add friend"
  26.     print "   2 - Delete friend"
  27.     print "   3 - Show friends"
  28.     print "   4 - Check Dates"
  29.     print ""
  30.     print "   0 - Save and Exit"
  31.     print ""
  32.     prin "   Choice: "
  33.   ]
  34.  
  35.   addFriend: make function! [fr]
  36.   [
  37.     print ""
  38.     print "Add a friend:"
  39.     print ""
  40.     prin "Name    : "
  41.     name: make string! input
  42.     prin "Surname : "
  43.     surname: make string! input
  44.     prin "e-mail  : "
  45.     email: make email! input
  46.     prin "Birthday: "
  47.     birthday: make date! input
  48.     print""
  49.   
  50.     insert tail fr make block! [name surname email birthday]
  51.   ]
  52.  
  53.   deleteFriend: make function! [fr]
  54.   [
  55.     print ""
  56.     print "Delete a friend:"
  57.     print ""
  58.     prin "Friend's e-mail: "
  59.     email: make email! input
  60.     remove/part (skip find fr email -2) 4
  61.   ]
  62.  
  63.   showFriends: make function! [fr]
  64.   [
  65.     print ""
  66.     print "   All entries in Database:"
  67.     print ""
  68.     forskip fr 4
  69.     [
  70.       print  ["   " first fr "" second fr "" third fr "" fourth fr]
  71.     ]
  72.   ]
  73.  
  74.   checkDates: make function! [fr]
  75.   [
  76.     print ""
  77.     print "   Checking for birthdays today..."
  78.     print ""
  79.     today: make date! reduce [first now second now third now]
  80.     forskip fr 4
  81.     [
  82.       birthday: make date! fourth fr
  83.       if ((first birthday) = (first today)) and ((second birthday) = (second today))
  84.       [
  85.          print [second fr "got Birthday!! Sending Birthday Greetings..."]
  86.          send third fr "Happy Birthday"
  87.          print "done!"
  88.       ]
  89.     ]
  90.   ]
  91.  
  92.   MainLoop: make function! []
  93.   [
  94.     loadFriends
  95.     while [choice <> "0"]
  96.     [
  97.       displayMenu []
  98.       choice: input
  99.       if choice = "1" [addFriend friends]
  100.       if choice = "2" [deleteFriend friends]
  101.       if choice = "3" [showFriends friends]
  102.       if choice = "4" [checkDates friends]
  103.     ]
  104.     Store friends
  105.   ]
  106.  
  107.   Check: make function! []
  108.   [
  109.     loadFriends
  110.     checkDates friends
  111.   ]
  112.  
  113.   Store: make function! [fr]
  114.   [
  115.     save %friends.dat fr
  116.   ]
  117. ]
  118.